
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<chiptrack:checkLogon sourcePage="distributorSales.do"/>
<%@ page import="com.scalar.chiptrack.utils.ConfigManager,java.util.Calendar,
                        com.scalar.chiptrack.utils.StringUtils"%>
<%@ page import="com.scalar.chiptrack.commons.Constants" %>
<%
    String chipTracContext = "/" + ConfigManager.getChipTracContext();
    String userTypeChiptrac = Constants.USER_TYPE_CHIPTRAC + "";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>

<META content="MSHTML 5.50.4807.2300" name=GENERATOR>
<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></script>
<script type="text/javascript">
function onLoad()
{
    loadNewEndCustomer();
}
function backToSearch()
{
    document.distributorSalesForm.action='<%=chipTracContext%>/distributorSalesSearch.do';
    document.distributorSalesForm.submit();
}
function cancelDistributorSalesOrder()
{
    document.distributorSalesForm.action = '<%=chipTracContext%>/distributorSales.do?action=cancel';
    document.distributorSalesForm.submit();
}
function closeDistributorSalesOrder()
{
    document.distributorSalesForm.action = '<%=chipTracContext%>/distributorSales.do?action=close';
    document.distributorSalesForm.submit();
}

function loadNewEndCustomer()
{
    var form = document.distributorSalesForm;
    var endCustomerCtrl = form.customer_Id;
    var endCustomerNameCtrl = form.newEndCustomerName;
    var endCustomerLabelSpan = document.getElementById ( "endCustomerLabelSpan" );
    var endCustomerTxfieldSpan = document.getElementById ( "endCustomerTxfieldSpan" );
    if ( endCustomerCtrl.value == "-2" )
    {
        endCustomerLabelSpan.style.display = 'block';
        endCustomerTxfieldSpan.style.display = 'block';
        endCustomerNameCtrl.disabled= true;
    }
    else
    {
        endCustomerNameCtrl.value = "";
        endCustomerLabelSpan.style.display = 'none';
        endCustomerTxfieldSpan.style.display = 'none';
    }
}

</script>
</HEAD>
<BODY bgColor="#ffffff" leftMargin=0 topMargin=0 marginheight="0" marginwidth="0" onLoad="javascript:onLoad();">
<!-- Top Header Start-->
<%@ include file="/jsp/includes/header.jsp" %>
<!-- Top Header End-->

<TABLE cellSpacing=0 cellPadding=0 width="100%" border="0">
	<TBODY>
	<TR>
		<td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>
            <!-- Side Navigation start -->
            <%--<%@ include file="/jsp/operations/operations_menu.jsp" %>--%>
            <logic:equal value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
                <%@ include file="/jsp/operations/operations_menu.jsp" %>
            </logic:equal>
            <logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
                <%@ include file="/jsp/admin/externaluser_menu.jsp" %>
            </logic:notEqual>
            <!-- end of the side navigations -->
		</td>
		<td bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=10></td>
		<td valign="top" width="100%">
			<IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0><BR>
            <!-- from here your body starts -->
			<html:form name="distributorSalesForm" method="post" action="/distributorSales" type="com.scalar.chiptrack.operations.distributor.forms.DistributorSalesForm" onsubmit="javascript:return searchDistributorSales();" >
			<table border="0" width="100%" align=right >
                <tr>
					<td><center><span class="NArialW">Distributor Sales </span></center><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td>
                </tr>
                <logic:equal  name="distributorSalesForm" property="distributorSalesOrder" value="1">
                <tr>
                    <td colspan='4'>
                        <font class='NArialL'><font color='red'>Are you sure, you want to cancel this Distributor Sales Order &nbsp;&nbsp;</font></font>
                        <chiptrack:restrictedLink functionality='<%=Functionality.PACKING_SLIP%>' action='<%=User.USER_ACTION_MODIFY%>' href='javascript:cancelDistributorSalesOrder();' onmouseover="window.status='Cancel this Distributor Sales Order';return true" onmouseout="window.status='';return true"><img src='<%=chipTracContext%>/jsp/includes/images/cancel.gif'  border='0'></chiptrack:restrictedLink>
                        &nbsp;&nbsp;&nbsp;&nbsp;
                    </td>
                </tr>
                </logic:equal>
                <logic:equal  name="distributorSalesForm" property="distributorSalesOrder" value="2">
                <tr>
                    <td colspan='4'>
                        <font class='NArialL'><font color='red'>Are you sure, you want to Close this Distributor Sales Order &nbsp;&nbsp;</font></font>
                        <chiptrack:restrictedLink functionality='<%=Functionality.PACKING_SLIP%>' action='<%=User.USER_ACTION_MODIFY%>' href='javascript:closeDistributorSalesOrder();' onmouseover="window.status='close this Distributor Sales Order';return true" onmouseout="window.status='';return true"><img src='<%=chipTracContext%>/jsp/includes/images/close.gif'  border='0'></chiptrack:restrictedLink>
                        &nbsp;&nbsp;&nbsp;&nbsp;
                    </td>
                </tr>
                </logic:equal>
                <tr>
					<td>
						<table border="0" width="100%" align=right>
                            <tr><td colspan=5 class="NArialL" align="left"><font color="FF0000"><FONT id="errors"></FONT></font></td></tr>
                            <tr><td colspan=5 id="svrErrors"><chiptrack:errors styleClass="NArialL"/></td></tr>
                            <tr><td colspan=5 id="svrInfo"><chiptrack:info styleClass="NArialL"/></td></tr>
                            <tr><td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
                            <tr>
                                <html:hidden name="distributorSalesForm" property="distSalesOrderId" />
                                <td width="15%" class="NArialL">Distributor Name</td>
                                <td width="15%" class="NArialL">
                                    <html:select name="distributorSalesForm"  property="distributorId" styleClass="txfield" disabled="true">
                                        <html:option value="0">--Select Distributor--</html:option>
                                        <html:options collection="distributorList" property="value" labelProperty="label"/>
                                    </html:select>
                                </td>
                                <td width="5%">&nbsp;</td>
                                <td width="15%" class="NArialL"><bean:message key="label.sales.shipToCustomer"/></td>
                                <td width="50%">
                                    <html:select name="distributorSalesForm"  property="customer_Id" styleClass="txfield" disabled="true" onchange="javascript:loadNewEndCustomer();">
                                        <html:option value="0">--Select <bean:message key="label.sales.shipToCustomer"/>--</html:option>
                                        <html:options collection="endCustomerList" property="value" labelProperty="label"/>
                                        <html:option value="-2" >----- New <bean:message key="label.sales.shipToCustomer"/>-----</html:option>
                                    </html:select>
                                </td>
                            </tr>
                            <tr>
                                <td width="25%" class="NArialL">&nbsp;</td>
                                <td width="20%" class="NArialL">&nbsp;</td>
                                <td width="5%">&nbsp;</td>
                                <td width="25%" class="NArialL"><span id="endCustomerLabelSpan" style="display:none">Add New <bean:message key="label.sales.shipToCustomer"/></span></td>
                                <td width="20%"><span id="endCustomerTxfieldSpan" style="display:none"><html:text name="distributorSalesForm" property="newEndCustomerName" styleClass="txfield" /></span></td>
                            </tr>
                            <tr>
                                <td class="NArialL">Sales Order#</td>
                                <td class="NArialL">
                                    <html:text name="distributorSalesForm" property="salesOrderNo" styleClass="txfield"  disabled="true"/>
                                </td>
                                <td>&nbsp;</td>
                                <td class="NArialL">Customer PO</td>
                                <td class="NArialL">
                                   <html:text name="distributorSalesForm" property="customerPO" styleClass="txfield"  disabled="true"/>
                                </td>
                            </tr>
                            <tr>
                                <td class="NArialL">Sales Order Date</td>
                                <td class="NArialL">
                                    <html:text name="distributorSalesForm" property="salesOrderDate" styleClass="txfield"  disabled="true"/>
                                </td>
                                <td>&nbsp;</td>
                                <td class="NArialL">&nbsp;</td>
                                <td class="NArialL">&nbsp;</td>
                            </tr>

                            <tr><td colspan='5'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td></tr>
                            <tr>
                                <td colspan='5' align="left">
                                    <table border="0" width="80%" align="left"  cellpadding="2" cellspacing="2">
                                        <tr><td colspan='10' align="left" class="NArialL">Line Item Details:</td></tr>
                                        <tr>
                                            <td width="5%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">Record No</font></td>
                                            <td width="4%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF"><bean:message key="label.sales.distributor.userField1"/></font></td>
                                            <td width="15%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">Part Number</font></td>
                                            <td width="7%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">Req Qty</font></td>
                                            <td width="10%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">Req Date</font></td>
                                            <td width="8%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">Shipped Qty</font></td>
                                            <td width="10%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">Ship Date</font></td>
                                            <td width="5%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">Unit Cost</font></td>
                                            <td width="5%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">Ext Cost</font></td>
                                            <td width="7%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">ReSale Price</font></td>
                                            <td width="8%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">Ext ReSale Price</font></td>
                                        </tr>
                                        <nested:iterate id="lineitem" property="lineItemList" type="com.scalar.chiptrack.operations.distributor.DistLineItem" indexId="lineItemIdx">
                                        <% int lineItemNoIdx = lineItemIdx.intValue() + 1; %>
                                        <tr>
                                            <td>
                                                 <nested:hidden property="lineItem_Id"/>
                                                <input type="hidden" name="noOflineItems"/>
                                                <nested:notEqual property="lineItemNo" value="-1">
                                                    <nested:text property="lineItemNo" size="3" maxlength="2" styleClass="txfield" disabled="true"/>
                                                </nested:notEqual>
                                            </td>
                                            <td><nested:text property="userDefinedField1" size="4" maxlength="10" styleClass="txfield"  disabled="true"/></td>
                                            <td>
                                                <nested:select property="productId"  styleClass="txfield"  disabled="true">
                                                     <html:options collection="productList" property="value" labelProperty="label" />
                                                </nested:select>
                                            </td>
                                            <td><nested:text property="qty_req" size="10" maxlength="10" styleClass="txfield"  disabled="true"/></td>
                                            <td>
                                                <nested:text property="req_date" size="13" maxlength="10"  styleClass="txfield"  disabled="true"/>
                                            </td>
                                            <td>
                                                <nested:text property="qtyShip" styleClass="txfield" disabled="true" size="10" maxlength="10" />
                                            </td>
                                            <td>
                                                <nested:text property="shipDate" size="13" maxlength="10"  styleClass="txfield"  disabled="true" />
                                            </td>
                                            <td><nested:text property="unitCost" styleClass="txfield"  size="10" maxlength="10"  disabled="true" /></td>
                                            <td><nested:text property="extCost" styleClass="txfield"  size="10" maxlength="10"   disabled="true" /></td>
                                            <td><nested:text property="reSalePrice" styleClass="txfield"  size="10" maxlength="10"  disabled="true" /></td>
                                            <td><nested:text property="extReSalePrice" styleClass="txfield"  size="10" maxlength="10"   disabled="true" /></td>
                                        </tr>
                                        </nested:iterate>
                                    </table>
                                </td>
                            </tr>
						<tr><td colspan='5'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td></tr>
						<tr><td colspan='5'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td></tr>
						<tr>
							<td colspan="5" align="center">
                                <a href="javascript:backToSearch();"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/back.gif" width="40" height="15" onmouseover="window.status='Click to Close';return true" onmouseout="window.status='';return true" title="Click here to Close"></a>
							</td>
						</tr>
						</table>
					</td>
				</tr>
			</table>
			</html:form>
<!-- body ends here -->
		</td>
	</tr>
	</tbody>
</TABLE>
<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->

</BODY>
</HTML>
